package progetto;

import peersim.core.CommonState;
import example.hot.InetCoordinates;

public class DynamicCoordinates extends example.hot.InetCoordinates {

	/** 2d future coordinates components. */
    private double futureX, futureY;
	
	public DynamicCoordinates(String prefix) {
		super(prefix);
		
		futureX = -1;
		futureY = -1;
	}

	public double getFutureX() {
		return futureX;
	}

	public void setFutureX(double futureX) {
		this.futureX = futureX;
	}

	public double getFutureY() {
		return futureY;
	}

	public void setFutureY(double futureY) {
		this.futureY = futureY;
	}
	
	
	public void updateCurrentCoord(double valueX, double valueY) {
	
		setX(updateValue(getX(), getFutureX(), valueX));
		setY(updateValue(getY(), getFutureY(), valueY));
		
	}
	
	private double updateValue(double coordStart, double coordArrive, double value) {
		if(coordStart < coordArrive)
			return coordStart + value;
		else if(coordStart > coordArrive) {
			return coordStart - value;
		} 
		//se arrivo qui significa che le due coordinate sono uguali
		
		return coordArrive;
	}
	
	
	public void resetFutureCoord() {
		setFutureX(-1);
		setFutureY(-1);
	}
	
	

}
